Part Number Hot Search : 
7F0S20E FSS130D1 YA868C15 2SD14 A7601 75N10 20LM3 AN124
Product Description
Full Text Search
 

To Download AN2957 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  june 2010 doc id 15550 rev 2 1/21 AN2957 application note implementing an rc5 infrared transmitter using the ir timer modulator of the stm8l10x microcontroller introduction ir (infrared) light is a popular means of wireless communication for remote control applications. many different protocol standards such as rc5, rc5x, rc6,? exist for transmitting commands via an infrared wireless interface. this application note describes the widely -used rc5 coding scheme from philips and presents a full working solution that implements a remote control device. this application uses the stm8l10x microc ontroller, it contains a powerful hardware modulator called irtim that combines signals from two internal timers to drive the ir interface. this feature makes the microcontrolle r especially well suited for applications that require ir signal generation capability. www.st.com
contents AN2957 2/21 doc id 15550 rev 2 contents 1 stm8l10x ir interface description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2 rc5 coding scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1 frame header description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 device addresses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 device instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 bit descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.5 rc5 frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.6 rc5 carrier frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2 rc5 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.3 rc5 flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.4 application flowcharts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4 application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5 hardware description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
AN2957 stm8l10x ir interface description doc id 15550 rev 2 3/21 1 stm8l10x ir inte rface description the ir digital interface is designed to output a digital signal to an infrared diode driver circuit. it can output a signal using any of the existi ng modulation styles, the modulation style is dependent on the software algorithm. the ir interface is very easy to configure and it uses 2 signals provided by two of the stm8l10x timers (tim2 and tim3). tim2 is used to provide the carrier frequency and tim3 provides the actual signal to be sent. figure 1. irtim input and output signals tim2_ch1 (carrier frequency) tim3_ch1 (main signal) irtim irtim_output
rc5 coding scheme AN2957 4/21 doc id 15550 rev 2 2 rc5 coding scheme the rc5 coding scheme from philips is a standard in infrar ed wireless command transmission. the rc5 coding scheme can generate 2048 different commands organized on 32 groups, each group has 64 different commands. the rc5 frame is a 14-bit word, composed of 3 parts: header (3 bits) device address (5 bits) device instruction (6 bits) the bits are transmitted in bi-phase code (also known as manchester code) as shown in figure 3 . the rc5 carrier frequency is 36 khz. figure 2. rc5 frame format figure 3. manchester coding header (3 bits) device address (5 bits) device instruction (6 bits) logic 0 logic 1
AN2957 rc5 coding scheme doc id 15550 rev 2 5/21 2.1 frame header description the frame header is composed of three bits: the two first bits are start bits, which always have the value "1". the next bit is a control bit, which is toggled every time a button is pressed on the remote control transmitter (to determine whether a button is pressed and held down, or pressed and released continuously). figure 4 and figure 5 show examples of rc5 frame headers: figure 4. frame header 1 figure 5. frame header 2 110 head1 (1st press) 1 1 1 head2 (2nd press)
rc5 coding scheme AN2957 6/21 doc id 15550 rev 2 2.2 device addresses the device address sequence is five bits long, allowing the control of up to 32 devices (2 5 = 32 addresses). ta b l e 1 gives the addresses of the controlled devices. table 1. rc5 device addresses address device 0tv1 1tv2 2 videotext 3 extension for tv1 and tv2 4 laser vision player 5 vcr1 6 vcr2 7 reserved 8sat1 9 extension for vcr1 and vcr2 10 sat2 11 reserved 12 cd-video 13 reserved 14 cd-photo 15 reserved 16 audio1 preamplifier 17 tuner 18 analogical magneto cassette 19 audio2 preamplifier 20 cd 21 rack audio 22 satellite receiver 23 dcc magneto 24 reserved 25 reserved 26 cd writable 27 to 31 reserved (for experimental use)
AN2957 rc5 coding scheme doc id 15550 rev 2 7/21 2.3 device instructions the instruction sequence is six bits long, allowing up to 64 (2 6 ) different instructions per address. there are two groups of instructions, the first group is common for all devices, the second group is reserved for televi sion devices (tv1 and tv2). common instructions are given in ta bl e 2 and tv instructions are given in ta bl e 3 . table 2. rc5 common instructions common instruct ion description 00 11 22 33 44 55 66 77 88 99 16 volume + 17 volume - 18 brightness + 19 brightness - 20 color saturation + 21 color saturation - 22 bass + 23 bass - 24 treble + 25 treble - 26 balance right 27 balance left 63 system select
rc5 coding scheme AN2957 8/21 doc id 15550 rev 2 table 3. rc5 tv instructions tv instruction description 10 1/2/3 digits / 10 11 freq./prog./ch./11 12 standby 13 mute/de-mute 14 personal pref. 15 display 28 contrast + 29 contrast - 30 search + 31 tint/hue - 32 ch./prog. + 33 ch./prog. - 36 spatial stereo 37 stereo/mono 38 sleep timer 39 tint/hue. + 40 rf switch 41 store/execute/vote 42 time 43 scan fwd./increment. 44 decrement 46 sec con/menu 47 show clock 48 pause 49 erase/correct 50 rewind 51 go to 52 wind 53 play 54 stop 55 record 56 external 1 57 external 2 59 advance 60 txt sub-mode/12
AN2957 rc5 coding scheme doc id 15550 rev 2 9/21 61 sys. standby 62 crispener table 3. rc5 tv instructions (continued) tv instruction description
rc5 coding scheme AN2957 10/21 doc id 15550 rev 2 2.4 bit descriptions rc5 bits are manchester coded, this means that a bit is composed of 2 alternated half bits. a low to high transition means that the bit is "1", a high to low transition means "0". the frequency used to code a bit is 562.429 hz (1778 s), half bits have the same width (889 s each). figure 6. rc5 bit description 2.5 rc5 frames rc5 frames are composed of 14 bits, the width of a frame is 24.892 ms (14 x 1.778 ms = 24.892 ms) to avoid frame collisions, an idle time is inse rted between two frames with a specific width. the idle time is defined as 50 bits wide. so the periodicity of a frame is 64 x 1 bit width: 64 x 1.778 = 113.792 ms (exactly 113.788 ms). figure 7. rc5 frame description "0" 889 s 1778 s 14 bits 50 bits 14 bits frame 1 idle time frame 2 64 bits = 113.788 ms
AN2957 rc5 coding scheme doc id 15550 rev 2 11/21 2.6 rc5 carrier frequency the rc5 carrier frequency is 36 khz. to minimize the power consumption, the duty cycle used for a pulse is fixed at 25%, so the width of a pulse is 6.94 s. figure 8. rc5 carrier frequency description 1 10 0 6.94 s 20.82 s carrier frequency frequency = 36 khz duty cycle = 25% main signal to send: manchester coded
software description AN2957 12/21 doc id 15550 rev 2 3 software description 3.1 introduction the software provided with this application note enables the user to send all rc5 instructions to all rc5 receiver devices. it contains an rc5 driver with functions and software flags. the software is designed to avoid frame collis ions; an idle time is inserted between two frames with a specific width (50 bits). the application uses 5 peripherals: irtim: (ir interface with timers) generates the ir signal using tim2 and tim3 tim2: (timer2) provides the carrier signal with a frequency of 36 khz tim3: (timer3) provides the main signal to be sent (rc5 frame) gpio: (general purpose i/o) provides the i/o to be connected to the buttons of the the remote control clk: (clock controller) enables the clocks and provides the correct clock frequency for the timers
AN2957 software description doc id 15550 rev 2 13/21 figure 9. application architecture and description main c application layer rc5 software layer rc5.h rc5.c stm8l10x.h stm8l10x_conf.h stm8l10x_it.h stm8l10x_it.c stm8l10x_tim3.c stm8l10x_tim3.h stm8l10x_tim2. stm8l10x_tim2.h stm8l10x_irtim.h stm8l10x_irtim.c stm8l10x_clk.h stm8l10x_clk.c stm8l10x_gpio.c stm8l10x_gpio.h api layer fw drivers hardware layer stm8l 10x microcontroller
software description AN2957 14/21 doc id 15550 rev 2 3.2 rc5 functions rc5_binframegeneration function generates and returns a binary format of the rc5 frame: the flowchart of this function is described below uint16_t rc5_binframegeneration ( rc5_address_typedef rc5_address, rc5_instruction_typedef rc5_instruction, rc5_ctrl_typedef rc5_ctrl) rc5_manchesterconvert function converts an rc5 binary format frame to a rc5 manchester format frame. uint32_t rc5_manchesterconvert (uint16_t rc5_binaryframeformat) rc5_sendframe function sends a manchester format rc5 frame. void rc5_sendframe(uint32_t rc5_manchesterframeformat) rc5_ctrlbitreverse function reverses the state of the rc5 control bit (can be used to determine whether a button is pressed and held down, or pressed and released continuously). rc5_ctrl_typedef rc5_ctrlbitreverse(rc5_ctrl_typedef rc5_ctrl); 3.3 rc5 flags table 4. rc5 flags flag name flag description send_operation_completed flag 0: the rc5 frame is not completely sent 1: the rc5 frame is completely sent send_operation_ready flag 0: the rc5 frame is not yet ready to be send 1: the rc5 frame is ready to be send
AN2957 software description doc id 15550 rev 2 15/21 3.4 application flowcharts figure 10. main loop flowchart identify which key is pressed and send the corresponding rc5 data if key is pressed enable and configure irtim to generate ir signal enable and configure tim3 to generate a periodic interrupt t = 889 s and enable the tim3 update interrupt enable and configure tim2 to generate the carrier signal frequency = 36 khz pwm duty cycle = 25% start no yes interrupt
software description AN2957 16/21 doc id 15550 rev 2 figure 11. send frame function flowchart end enable interrupts set the send_operation_ready flag to indicate that the frame is ready to be sent convert the frame to the manchester format disable interrupts generate a binary format of the frame begin sendframe
AN2957 software description doc id 15550 rev 2 17/21 figure 12. rc5 sendframe function flowchart (this function is called during the tim3 update interrupt routine) begin rc5_sendframe if flag send operation ready =1 yes no no no yes yes if all bits of the manchester format frame are sent clear flag send_operation_completed = 0 if the bit to be sent is 1 force the tim3 ch1 output to 1 force the tim3 ch1 output to 0 increment bitssent_counter (bitssent_counter++) set flag send_operation_completed = 1 reset bitssent_counter (bitssent_counter = 0) force the tim3 ch1 output to 0 end
application description AN2957 18/21 doc id 15550 rev 2 4 application description this application note is provided with a basic application in which only two keys are used for remote control: button 1 (pa5) enables user to send "volumeup" rc5 instruction to "tv1" (key button on stm8l1x-eval board). button 2 (pd7) enables user to send "volumedown" rc5 instruction to "tv1" (joystick select button on stm8l1x-eval board). however, user can implement a bigger remote control to fit its application needs. figure 13. simplified rc5 transmitter s tm 8 l10x b u tton 2 b u tton 1 pd7 pa5 pa 0 not ir led gnd
AN2957 hardware description doc id 15550 rev 2 19/21 5 hardware description figure 14. rc5 transmitter rc5 remote control gnd ir led r2=100 vcc r1=10k port b port d stm8l 10x
revision history AN2957 20/21 doc id 15550 rev 2 6 revision history table 5. document revision history date revision changes 23-apr-2009 1 initial release. 04-jun-2010 2 removed several common instructions (from 71 to 124) in table 2: rc5 common instructions on page 7 removed several tv instructions (from 70 to 127) in ta b l e 3 : rc5 tv instructions on page 8
AN2957 doc id 15550 rev 2 21/21 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2010 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2957

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X